package day15;

import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

/**
 * 需求：往TreeSet集合中存储自定义的学生对象
 * 想按照学生的年龄进行排序
 * @author wangbiao
 *
 */
public class TreeSetTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Set<Student> set = new TreeSet<Student>();
		set.add(new Student("wangbiao", 21));
		set.add(new Student("zhangsan", 20));
		set.add(new Student("lisi", 22));
		set.add(new Student("wangwu2", 19));
		set.add(new Student("wangwu1", 19));
		
		for (Iterator<Student> iterator = set.iterator(); iterator.hasNext();) {
			Student student = iterator.next();
			System.out.println(student);
			
		}
		
	}

}

